<?php

namespace app\site\controller\sys;

use app\model\sys\UploadFile;
use app\Request;
use app\site\controller\AController;
use app\site\service\RequestService;
use app\site\service\site\UploadFileService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use function jsonSuccess;

class UploadFileController extends AController
{

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public function index(): \think\response\Json
    {
        return $this->reqSer->setService(UploadFileService::instance())->setPaginate()->getResponse();
    }

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public function del(): \think\response\Json
    {
        $ids = $this->param('ids');
        UploadFileService::instance()->setWhere([
            ['id', 'in', $ids]
        ])->delete();
        return jsonSuccess();
    }

}
